<?php 
  include("common/conn.php");  
  include("./tool/UpFileTool.class.php");
  if($_GET['action']=="ok")
  {    
if ($_FILES) {
  $UpFileTool=new UpFileTool('upfile');
  $UpFileTool->sumbImage($w=500, $h=500);
  $UpFileTool->upFile();
  $images = $UpFileTool->sumbImage;
  $srcimages = $UpFileTool->srcImage;
}

$date=date("Y-m-d h:i:s");

$srat=mysql_query("INSERT INTO user(niname,sex,money,phone,images,srcimages,tel,province,city,password) VALUES ('$_REQUEST[niname]','$_REQUEST[sex]','$_REQUEST[money]','$_REQUEST[phone]','$images','$srcimages','$_REQUEST[tel]','$_REQUEST[province]','$_REQUEST[city]','$_REQUEST[password]')");

$dingid=mysql_insert_id();

$srat=mysql_query("INSERT INTO guanli(shopid,userid) VALUES ('$_POST[shopid]','$dingid')");


$conn=mysql_connect('localhost','root','') or die('连接失败！'.mysql_error());
mysql_select_db('xzsh',$conn) or die('数据库选择失败:' . mysql_error());
mysql_select_db('db');mysql_query("set names utf8;"); //**设置字符集***

$srat=mysql_query("INSERT INTO shop(shopid,name,phone,password,city,tel) VALUES ('$dingid','$_REQUEST[niname]','$_REQUEST[phone]','$_REQUEST[password]','$_REQUEST[city]','$_REQUEST[tel]')");




echo "<script>window.location.href='user.php';</script>";
}

if($_GET['id']!=""){

  $rert36=mysql_query("select * from user where  userid = '".$_GET['id']."'");
  $sdg37=mysql_fetch_array($rert36);

  $rert37=mysql_query("select * from shop  where  shopid = '".$sdg35[shopid]."'");
  $sdg36=mysql_fetch_array($rert37);

}


if($_GET['ch']=="ok")
{    
$rert35=mysql_query("select * from user where userid='".$_REQUEST['id']."'");
$sdg35=mysql_fetch_array($rert35);

$srat1=mysql_query("update guanli set shopid='".$_POST['shopid']."' where id='".$_REQUEST['id']."'");
  $srat1=mysql_query("update user set niname='".$_POST['niname']."',sex='".$_POST['sex']."',money='".$_POST['money']."',phone='".$_POST['phone']."',tel='".$_POST['tel']."',province='".$_POST['province']."',city='".$_POST['city']."' where userid='".$sdg35['userid']."'");
if ($_FILES[upfile][tmp_name]!='') {
  $UpFileTool=new UpFileTool('upfile');
  $UpFileTool->sumbImage($w=500, $h=500);
  $UpFileTool->upFile();
  $images = $UpFileTool->sumbImage;
  $srcimages = $UpFileTool->srcImage;
  $srat1=mysql_query("update user set images='".$images."',srcimages='".$srcimages."' where userid='".$sdg35['userid']."'");
}




echo "<script>window.location.href='user.php';</script>";
}


?>
